package com.skyc.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.skyc.entity.Clothes;
import com.skyc.entity.User;
import com.skyc.service.collectionService;
import com.skyc.service.liuLanService;
import com.skyc.service.impl.collectionServiceImpl;
import com.skyc.service.impl.liulanServiceImpl;

/**
 * Servlet implementation class toindexServlet
 */
@WebServlet("/dowomenServlet")
public class dowomenServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doPost(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		HttpSession session = request.getSession();
		int type = Integer.valueOf(request.getParameter("type"));//需要女装 类型
		liuLanService ls = new liulanServiceImpl();
		List<Clothes> womenList=(List<Clothes>) session.getAttribute("womenList");
		if(type==1) {
			womenList = ls.queryByType("女","上装");
			for (Clothes c : womenList) {
				c.setCimgurl(c.getCimgurl().substring(0, c.getCimgurl().indexOf('/')));
			}
		}
		
		if(type==2) {
			womenList = ls.queryByType("女","下装");
			for (Clothes c : womenList) {
				c.setCimgurl(c.getCimgurl().substring(0, c.getCimgurl().indexOf('/')));
			}
		}
		
		if(type==3) {
			womenList = ls.queryByType("女","套装");
			for (Clothes c : womenList) {
				c.setCimgurl(c.getCimgurl().substring(0, c.getCimgurl().indexOf('/')));
			}
		}
		if(type==-1) {
			 womenList = ls.NZqueryByID("女");
			 for (Clothes c : womenList) {
					c.setCimgurl(c.getCimgurl().substring(0, c.getCimgurl().indexOf('/')));
				}
		}
		
		session.setAttribute("womenList", womenList);
		request.getRequestDispatcher("indextypeshow.jsp").forward(request, response);

	}
}
